home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / ape-ad1a / cdxvbtyp.cls < prev    next >
Text File  |  1999-09-09  |  2KB  |  58 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "CDXVBTypewriter"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. ' Typewriter class. Also requires VBTypeWriter.bas
  15.  
  16. ' X and Y offset of text on the hDC
  17. Public X As Long, Y As Long
  18. ' The current character number. Should only be read
  19. Public CurCharNo As Integer
  20.  
  21. Public Sub NextLine()
  22.     ' Add 12 to Y, moves onto next line for typing
  23.     Y = Y + 12
  24. End Sub
  25.  
  26. Public Function Draw(hDC As Long, text As String, RGBcolor As Long) As Integer
  27.     ' The actual string to be typed
  28.     Dim theString As String
  29.     ' Number of times the function has needs to be executed
  30.     Static times As Integer
  31.     
  32.     ' Set the typewriter is still typing by default
  33.     Draw = TW_STILLTYPING
  34.     
  35.     ' Increase times the function has been called
  36.     times = times + 1
  37.     ' If we have finished typing the line of text, exit
  38.     If times > Len(text) Then times = 1: Draw = TW_DONETYPING: Exit Function
  39.     
  40.     ' Fill the string to be typed
  41.     theString = Mid(text, 1, times)
  42.     
  43.     ' Set the current character number
  44.     CurCharNo = times
  45.     
  46.     ' Set the text color
  47.     SetTextColor hDC, RGBcolor
  48.     
  49.     ' Output the text onto the hDC
  50.     TextOut hDC, X, Y, theString & Chr(10), Len(theString & Chr(10))
  51. End Function
  52.  
  53. Private Sub Class_Initialize()
  54.     ' Set the default values
  55.     X = Y = 0
  56.     CurCharNo = 0
  57. End Sub
  58.